﻿var infoWindow;
var data =  window.parent.App.singleMap;
var point_arry = data.site.split(",");
var lng = point_arry[0];
var lat = point_arry[1];
var map = new AMap.Map("container_goMap", {
    resizeEnable: true,
    center: [lng, lat],//[116.473188, 39.993253],
    zoom: 13
});
addMarker();
function addMarker() {
    map.clearMap();
    var marker = new AMap.Marker({
        map: map,
        position: [lng, lat]//[116.473188, 39.993253]
    });

}
//构建自定义信息窗体
function createInfoWindow(title, content) {
    var info = document.createElement("div");
    info.className = "info";

    //可以通过下面的方式修改自定义窗体的宽高
    //info.style.width = "400px";
    // 定义顶部标题
    var top = document.createElement("div");
    var titleD = document.createElement("div");

    top.className = "info-top";
    titleD.innerHTML = title;

    top.appendChild(titleD);
    info.appendChild(top);

    // 定义中部内容
    var middle = document.createElement("div");
    middle.className = "info-middle";
    middle.style.backgroundColor = 'white';
    middle.innerHTML = content;
    info.appendChild(middle);

    // 定义底部内容
    var bottom = document.createElement("div");
    bottom.className = "info-bottom";
    bottom.style.position = 'relative';
    bottom.style.top = '0px';
    bottom.style.margin = '0 auto';
    var sharp = document.createElement("img");
    sharp.src = "http://webapi.amap.com/images/sharp.png";
    bottom.appendChild(sharp);
    info.appendChild(bottom);
    return info;
}
//在指定位置打开信息窗体
function openInfo() {
    var address = data.province + data.city + data.area + data.address;
    //构建信息窗体中显示的内容
    var title = data.name + '<span style="font-size:11px;color:#F00;"></span>',
    content = [];
    content.push("<img src='" + data.picture + "' style='width:60px;height:60px;'>地址：" + address);

    /*content.push("电话：010-64733333");*/
    content.push("");
    infoWindow = new AMap.InfoWindow({
        isCustom: true,  //使用自定义窗体
        content: createInfoWindow(title, content.join("<br/>")),
        offset: new AMap.Pixel(16, -45)

    });
    infoWindow.open(map, map.getCenter());
}
openInfo();

function gotomapcont() {
    map.panTo([lng, lat]);//([116.473188, 39.993253]);
}